package com.foreknow.springboot_demo.controller;

import com.foreknow.springboot_demo.po.Orders;
import com.foreknow.springboot_demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/OrdersController")
public class OrdersController {

    @Autowired
    private OrderService orderService;

    @RequestMapping("/createOrders")
    public Integer createOrders(Orders orders){
        return orderService.createOrders(orders.getUserId(),orders.getBusinessId(),orders.getDaId(),orders.getOrderTotal());
    }


    @RequestMapping("/getOrdersById")
    public Orders getOrdersById(Orders orders){
        return orderService.getOrdersById(orders.getOrderId());
    }


    @RequestMapping("/listOrdersByUserId")
    public List<Orders> listOrdersByUserId(Orders orders){
        return orderService.listOrdersByUserId(orders.getUserId());
    }

}
